package com.gsta.cdn.cdr.mapper;


import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.gsta.cdn.cdr.entity.ResultEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Mapper
@Component(value = "ResolutionTypeMapper")
public interface ResolutionTypeMapper extends BaseMapper<ResultEntity> {
    @Select("<script>" +
            " SELECT * FROM ResolutionTypeAll  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} "+
            "ORDER BY Hour " +
            "LIMIT #{page},#{pageSize} "+
            "</script>")
    List<Map<String, Object>> ResolutionTypeAll(@Param("Date") String Date, @Param("Percent") String Percent,@Param("page") int page, @Param("pageSize") int pageSize);

    @Select("<script>" +
            "SELECT COUNT(*) AS count FROM ( " +
            " SELECT * FROM ResolutionTypeAll  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent})t  "+
            "</script>")
    int ResolutionTypeAllCount (@Param("Date") String Date, @Param("Percent") String Percent);

    @Select("<script>" +
            " SELECT DISTINCT Area FROM ResolutionTypeArea  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} "+
            "ORDER BY Area " +
            "</script>")
    List<Map<String, Object>> ResolutionTypeArea(@Param("Date") String Date, @Param("Percent") String Percent);

    @Select("<script>" +
            " SELECT * FROM ResolutionTypeArea  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND Area=#{Area} "+
            "ORDER BY Hour " +
            "LIMIT #{page},#{pageSize} "+
            "</script>")
    List<Map<String, Object>> ResolutionTypeByArea(@Param("Date") String Date, @Param("Percent") String Percent, @Param("Area") String Area,@Param("page") int page, @Param("pageSize") int pageSize);



    @Select("<script>" +
            "SELECT COUNT(*) AS count FROM ( " +
            " SELECT * FROM ResolutionTypeArea  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND Area=#{Area})t  "+
            "</script>")
    int ResolutionTypeByAreaCount (@Param("Date") String Date, @Param("Percent") String Percent,@Param("Area") String Area);


    @Select("<script>" +
            " SELECT DISTINCT PopName FROM ResolutionTypeAreaPopName  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND Area=#{Area} "+
            "ORDER BY PopName " +
            "</script>")
    List<Map<String, Object>> ResolutionTypeAreaPopName(@Param("Date") String Date, @Param("Percent") String Percent,@Param("Area") String Area);

    @Select("<script>" +
            " SELECT * FROM ResolutionTypeAreaPopName  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND Area=#{Area} AND PopName=#{PopName} "+
            "ORDER BY Hour " +
            "LIMIT #{page},#{pageSize} "+
            "</script>")
    List<Map<String, Object>> ResolutionTypeByAreaPopName(@Param("Date") String Date, @Param("Percent") String Percent, @Param("Area") String Area
            ,@Param("PopName") String PopName,@Param("page") int page, @Param("pageSize") int pageSize);

    @Select("<script>" +
            "SELECT COUNT(*) AS count FROM ( " +
            " SELECT * FROM ResolutionTypeAreaPopName  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND Area=#{Area} AND PopName=#{PopName} )t  "+
            "</script>")
    int ResolutionTypeByAreaPopNameCount (@Param("Date") String Date, @Param("Percent") String Percent,@Param("Area") String Area,@Param("PopName") String PopName);


    @Select("<script>" +
            " SELECT * FROM ResolutionTypePopName  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND PopName=#{PopName} "+
            "ORDER BY Hour " +
            "LIMIT #{page},#{pageSize} "+
            "</script>")
    List<Map<String, Object>> ResolutionTypeByPopName(@Param("Date") String Date, @Param("Percent") String Percent
            ,@Param("PopName") String PopName,@Param("page") int page, @Param("pageSize") int pageSize);

    @Select("<script>" +
            "SELECT COUNT(*) AS count FROM ( " +
            " SELECT * FROM ResolutionTypePopName  " +
            " WHERE Date = #{Date}  AND Percent=#{Percent} AND PopName=#{PopName} )t  "+
            "</script>")
    int ResolutionTypeByPopNameCount (@Param("Date") String Date, @Param("Percent") String Percent,@Param("PopName") String PopName);


}
